package com.eascs.admin.o2o.notify.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import com.eascs.admin.common.dao.BaseO2oDao;
import com.eascs.admin.o2o.notify.entity.RabbitMsgRecord;
import com.eascs.admin.o2o.notify.entity.WFStatus;

@Repository
public class WFStatusDao extends BaseO2oDao {

	public WFStatus getByReferIdAndProcessId(String referId, String processId) {
		String sql = "select * from o2o_wf_status where refer_id = ? and process_id = ?";
		WFStatus wfStatus = o2oJdbcSession.findEntity(sql, WFStatus.class, referId, processId);
		return wfStatus;
	}
	
	public int insertRabbitMsgRecord(RabbitMsgRecord record){
		return this.insert(record);
	}
	
	public RabbitMsgRecord queryRabbitMsgRecordByUniqueCode(String uniqueCode){
		String sql ="SELECT * FROM o2o_rabbitmq_msg WHERE unique_code = ?";
		return this.findEntity(sql, RabbitMsgRecord.class, uniqueCode);
	}
	
	public List<RabbitMsgRecord> queryRabbitMsgRecordList(){
		String sql ="SELECT * FROM o2o_rabbitmq_msg WHERE status = 0";
		return this.findEntitys(sql, RabbitMsgRecord.class, new Object[]{});
	}
	
	public int rabbitMsgSucc(String uniqueCode){
		String sql="update o2o_rabbitmq_msg set status = 1 where unique_code = ?";
		return this.execute(sql, new Object[]{uniqueCode});
	}
	
}
